1 module core.stdc.stdio; 2 3 /* 4 * Copyright (c) 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms are permitted 8 * provided that the above copyright notice and this paragraph are 9 * duplicated in all such forms and that any documentation, 10 * and/or other materials related to such 11 * distribution and use acknowledge that the software was developed 12 * by the University of California, Berkeley. The name of the 13 * University may not be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 18 * 19 * @(#)stdio.h 5.3 (Berkeley) 3/15/86 20 */ 21 22 /* 23 * NB: to fit things in six character monocase externals, the 24 * stdio code uses the prefix `__s' for stdio objects, typically 25 * followed by a three-character attempt at a mnemonic. 26 */ 27 28 29 // #include "_ansi.h" 30 enum _FSTDIO; /* ``function stdio'' */ 31 32 import core.stdc.stddef; 33 // #include <sys/cdefs.h> 34 35 /* typedef only __gnuc_va_list, used throughout the header */ 36 import core.stdc.stdarg; 37 38 /* 39 * <sys/reent.h> defines __FILE, _fpos_t. 40 * They must be defined there because struct _reent needs them (and we don't 41 * want reent.h to include this file. 42 */ 43 44 // #include <sys/reent.h> 45 // #include <sys/types.h> 46 47 struct FILE; 48 49 // #include <sys/stdio.h> 50 51 enum __SLBF = 0x0001; /* line buffered */ 52 enum __SNBF = 0x0002; /* unbuffered */ 53 enum __SRD = 0x0004; /* OK to read */ 54 enum __SWR = 0x0008; /* OK to write */ 55 /* RD and WR are never simultaneously asserted */ 56 enum __SRW = 0x0010; /* open for reading & writing */ 57 enum __SEOF = 0x0020; /* found EOF */ 58 enum __SERR = 0x0040; /* found error */ 59 enum __SMBF = 0x0080; /* _buf is from malloc */ 60 enum __SAPP = 0x0100; /* fdopen()ed in append mode - so must write to end */ 61 enum __SSTR = 0x0200; /* this is an sprintf/snprintf string */ 62 enum __SOPT = 0x0400; /* do fseek() optimisation */ 63 enum __SNPT = 0x0800; /* do not do fseek() optimisation */ 64 enum __SOFF = 0x1000; /* set iff _offset is in fact correct */ 65 enum __SORD = 0x2000; /* true => stream orientation (byte/wide) decided */ 66 version(Cygwin) 67 enum __SCLE = 0x4000; /* convert line endings CR/LF <-> NL */ 68 enum __SL64 = 0x8000; /* is 64-bit offset large file */ 69 70 /* _flags2 flags */ 71 enum __SNLK = 0x0001; /* stdio functions do not lock streams themselves */ 72 enum __SWID = 0x2000; /* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */ 73 74 /* 75 * The following three definitions are for ANSI C, which took them 76 * from System V, which stupidly took internal interface macros and 77 * made them official arguments to setvbuf(), without renaming them. 78 * Hence, these ugly _IOxxx names are *supposed* to appear in user code. 79 * 80 * Although these happen to match their counterparts above, the 81 * implementation does not rely on that (so these could be renumbered). 82 */ 83 enum _IOFBF = 0; /* setvbuf should set fully buffered */ 84 enum _IOLBF = 1; /* setvbuf should set line buffered */ 85 enum _IONBF = 2; /* setvbuf should set unbuffered */ 86 87 enum EOF = -1; 88 89 enum BUFSIZ = 1024; 90 91 enum FOPEN_MAX =20; 92 enum FILENAME_MAX =1024; 93 94 enum L_tmpnam = FILENAME_MAX; 95 96 enum P_tmpdir = "/tmp"; 97 98 enum SEEK_SET = 0; 99 enum SEEK_CUR = 1; 100 enum SEEK_END = 2; 101 102 version(PSVita) 103 { 104 struct _reent //Minimal required 105 { 106 int _errno; 107 FILE* stdint, stdout, stderr; 108 } 109 110 extern(C) _reent* getreent(); 111 112 FILE* stdout (){return getreent().stdout;} 113 } 114 115 // enum stdin (_REENT->_stdin) 116 // #define stdout (_REENT->_stdout) 117 // #define stderr (_REENT->_stderr) 118 119 // #define _stdin_r(x) ((x)->_stdin) 120 // #define _stdout_r(x) ((x)->_stdout) 121 // #define _stderr_r(x) ((x)->_stderr) 122 123 /* 124 * Functions defined in ANSI C standard. 125 */ 126 127 128 version(WebAssembly) 129 { 130 extern(C) FILE* fopen (const(char*) _name, const(char*) _type){return null;} 131 extern(C) c_long ftell ( FILE *){return EOF;} 132 extern(C) size_t fread (void *, size_t _size, size_t _n, FILE *){return 0;} 133 extern(C) int fgetc (FILE *){return EOF;} 134 extern(C) size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream){return 0;} 135 extern(C) int fflush(FILE *stream){return EOF;} 136 extern(C) int remove(const char *filename){return -1;} 137 extern(C) int fputc (int, FILE *){return EOF;} 138 extern(C) int fseek (FILE *, c_long, int){return EOF;} 139 extern(C) int fclose (FILE *){return -1;} 140 } 141 else 142 { 143 extern(C) nothrow @nogc: 144 extern FILE * tmpfile (); 145 extern char * tmpnam (char *); 146 extern char * tempnam (char *, char*); 147 extern int fclose (FILE *); 148 extern int fflush (FILE *); 149 extern FILE * freopen (const(char*), const(char*), FILE *); 150 extern void setbuf (FILE *, char *); 151 extern int setvbuf (FILE *, char *, int, size_t); 152 extern int fprintf (FILE *, const(char*), ...); 153 extern int fscanf (FILE *, const(char*), ...); 154 extern int printf (const(char*), ...); 155 extern int scanf (const(char*), ...); 156 extern int sscanf (const(char*), const(char*), ...); 157 // extern int vfprintf (FILE *, const(char*), __VALIST); 158 // extern int vprintf (const(char*), __VALIST); 159 // extern int vsprintf (char *, const(char*), __VALIST); 160 extern int fgetc (FILE *); 161 extern char * fgets (char *, int, FILE *); 162 extern int fputc (int, FILE *); 163 extern int fputs (const(char*), FILE *); 164 extern int getc (FILE *); 165 extern int getchar (); 166 extern char * gets (char *); 167 extern int putc (int, FILE *); 168 extern int putchar (int); 169 extern int puts (const(char*)); 170 extern int ungetc (int, FILE *); 171 extern size_t fread (void *, size_t _size, size_t _n, FILE *); 172 extern size_t fwrite (const void * , size_t _size, size_t _n, FILE *); 173 // extern int fgetpos (FILE *, fpos_t *); 174 extern int fseek (FILE *, c_long, int); 175 // extern int fsetpos (FILE *, const fpos_t *); 176 extern c_long ftell ( FILE *); 177 extern void rewind (FILE *); 178 extern void clearerr (FILE *); 179 extern int feof (FILE *); 180 extern int ferror (FILE *); 181 extern void perror (const(char*)); 182 extern FILE * fopen (const(char*) _name, const(char*) _type); 183 extern int sprintf (char *, const(char*), ...); 184 extern int remove (const(char*)); 185 extern int rename (const(char*), const(char*)); 186 } 187 188 // extern(C) extern int fseeko (FILE *, _off_t, int); 189 // #if __GNU_VISIBLE 190 // int fcloseall (void); 191 // #endif 192 // #ifndef _REENT_ONLY 193 // #if __ISO_C_VISIBLE >= 1999 194 // int snprintf (char *, size_t, const(char*), ...) 195 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 196 // int vsnprintf (char *, size_t, const(char*), __VALIST) 197 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 198 // int vfscanf (FILE *, const(char*), __VALIST) 199 // _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); 200 // int vscanf (const(char*), __VALIST) 201 // _ATTRIBUTE ((__format__ (__scanf__, 1, 0))); 202 // int vsscanf (const(char*), const(char*), __VALIST) 203 // _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); 204 // #endif 205 // #if __GNU_VISIBLE 206 // int asprintf (char **, const(char*), ...) 207 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 208 // int vasprintf (char **, const(char*), __VALIST) 209 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 210 // #endif 211 // #if __MISC_VISIBLE /* Newlib-specific */ 212 // int asiprintf (char **, const(char*), ...) 213 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 214 // char * asniprintf (char *, size_t *, const(char*), ...) 215 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 216 // char * asnprintf (char *, size_t *, const(char*), ...) 217 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 218 // #ifndef diprintf 219 // int diprintf (int, const(char*), ...) 220 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 221 // #endif 222 // int fiprintf (FILE *, const(char*), ...) 223 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 224 // int fiscanf (FILE *, const(char*), ...) 225 // _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); 226 // int iprintf (const(char*), ...) 227 // _ATTRIBUTE ((__format__ (__printf__, 1, 2))); 228 // int iscanf (const(char*), ...) 229 // _ATTRIBUTE ((__format__ (__scanf__, 1, 2))); 230 // int siprintf (char *, const(char*), ...) 231 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 232 // int siscanf (const(char*), const(char*), ...) 233 // _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); 234 // int sniprintf (char *, size_t, const(char*), ...) 235 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 236 // int vasiprintf (char **, const(char*), __VALIST) 237 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 238 // char * vasniprintf (char *, size_t *, const(char*), __VALIST) 239 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 240 // char * vasnprintf (char *, size_t *, const(char*), __VALIST) 241 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 242 // int vdiprintf (int, const(char*), __VALIST) 243 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 244 // int vfiprintf (FILE *, const(char*), __VALIST) 245 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 246 // int vfiscanf (FILE *, const(char*), __VALIST) 247 // _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); 248 // int viprintf (const(char*), __VALIST) 249 // _ATTRIBUTE ((__format__ (__printf__, 1, 0))); 250 // int viscanf (const(char*), __VALIST) 251 // _ATTRIBUTE ((__format__ (__scanf__, 1, 0))); 252 // int vsiprintf (char *, const(char*), __VALIST) 253 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 254 // int vsiscanf (const(char*), const(char*), __VALIST) 255 // _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); 256 // int vsniprintf (char *, size_t, const(char*), __VALIST) 257 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 258 // #endif /* __MISC_VISIBLE */ 259 // #endif /* !_REENT_ONLY */ 260 261 // /* 262 // * Routines in POSIX 1003.1:2001. 263 // */ 264 265 // #if __POSIX_VISIBLE 266 // #ifndef _REENT_ONLY 267 // FILE * fdopen (int, const(char*)); 268 // #endif 269 // int fileno (FILE *); 270 // #endif 271 // #if __MISC_VISIBLE || __POSIX_VISIBLE >= 199209 272 // int pclose (FILE *); 273 // FILE * popen (const(char*), const(char*)); 274 // #endif 275 276 // #if __BSD_VISIBLE 277 // void setbuffer (FILE *, char *, int); 278 // int setlinebuf (FILE *); 279 // #endif 280 281 // #if __MISC_VISIBLE || (__XSI_VISIBLE && __POSIX_VISIBLE < 200112) 282 // int getw (FILE *); 283 // int putw (int, FILE *); 284 // #endif 285 // #if __MISC_VISIBLE || __POSIX_VISIBLE 286 // int getc_unlocked (FILE *); 287 // int getchar_unlocked (void); 288 // void flockfile (FILE *); 289 // int ftrylockfile (FILE *); 290 // void funlockfile (FILE *); 291 // int putc_unlocked (int, FILE *); 292 // int putchar_unlocked (int); 293 // #endif 294 295 // /* 296 // * Routines in POSIX 1003.1:200x. 297 // */ 298 299 // #if __POSIX_VISIBLE >= 200809 300 // # ifndef _REENT_ONLY 301 // # ifndef dprintf 302 // int dprintf (int, const(char*), ...) 303 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 304 // # endif 305 // FILE * fmemopen (void *, size_t, const(char*)); 306 // /* getdelim - see __getdelim for now */ 307 // /* getline - see __getline for now */ 308 // FILE * open_memstream (char **, size_t *); 309 // int vdprintf (int, const(char*), __VALIST) 310 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 311 // # endif 312 // #endif 313 // #if __ATFILE_VISIBLE 314 // int renameat (int, const(char*), int, const(char*)); 315 // # ifdef __CYGWIN__ 316 // int renameat2 (int, const(char*), int, const(char*), unsigned int); 317 // # endif 318 // #endif 319 320 // /* 321 // * Recursive versions of the above. 322 // */ 323 324 // int _asiprintf_r (struct _reent *, char **, const(char*), ...) 325 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 326 // char * _asniprintf_r (struct _reent *, char *, size_t *, const(char*), ...) 327 // _ATTRIBUTE ((__format__ (__printf__, 4, 5))); 328 // char * _asnprintf_r (struct _reent *, char *, size_t *, const(char*), ...) 329 // _ATTRIBUTE ((__format__ (__printf__, 4, 5))); 330 // int _asprintf_r (struct _reent *, char **, const(char*), ...) 331 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 332 // int _diprintf_r (struct _reent *, int, const(char*), ...) 333 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 334 // int _dprintf_r (struct _reent *, int, const(char*), ...) 335 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 336 // int _fclose_r (struct _reent *, FILE *); 337 // int _fcloseall_r (struct _reent *); 338 // FILE * _fdopen_r (struct _reent *, int, const(char*)); 339 // int _fflush_r (struct _reent *, FILE *); 340 // int _fgetc_r (struct _reent *, FILE *); 341 // int _fgetc_unlocked_r (struct _reent *, FILE *); 342 // char * _fgets_r (struct _reent *, char *, int, FILE *); 343 // char * _fgets_unlocked_r (struct _reent *, char *, int, FILE *); 344 // #ifdef _COMPILING_NEWLIB 345 // int _fgetpos_r (struct _reent *, FILE *, _fpos_t *); 346 // int _fsetpos_r (struct _reent *, FILE *, const _fpos_t *); 347 // #else 348 // int _fgetpos_r (struct _reent *, FILE *, fpos_t *); 349 // int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); 350 // #endif 351 // int _fiprintf_r (struct _reent *, FILE *, const(char*), ...) 352 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 353 // int _fiscanf_r (struct _reent *, FILE *, const(char*), ...) 354 // _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); 355 // FILE * _fmemopen_r (struct _reent *, void *, size_t, const(char*)); 356 // FILE * _fopen_r (struct _reent *, const(char*), const(char*)); 357 // FILE * _freopen_r (struct _reent *, const(char*), const(char*), FILE *); 358 // int _fprintf_r (struct _reent *, FILE *, const(char*), ...) 359 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 360 // int _fpurge_r (struct _reent *, FILE *); 361 // int _fputc_r (struct _reent *, int, FILE *); 362 // int _fputc_unlocked_r (struct _reent *, int, FILE *); 363 // int _fputs_r (struct _reent *, const(char*), FILE *); 364 // int _fputs_unlocked_r (struct _reent *, const(char*), FILE *); 365 // size_t _fread_r (struct _reent *, void *, size_t _size, size_t _n, FILE *); 366 // size_t _fread_unlocked_r (struct _reent *, void *, size_t _size, size_t _n, FILE *); 367 // int _fscanf_r (struct _reent *, FILE *, const(char*), ...) 368 // _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); 369 // int _fseek_r (struct _reent *, FILE *, long, int); 370 // int _fseeko_r (struct _reent *, FILE *, _off_t, int); 371 // long _ftell_r (struct _reent *, FILE *); 372 // _off_t _ftello_r (struct _reent *, FILE *); 373 // void _rewind_r (struct _reent *, FILE *); 374 // size_t _fwrite_r (struct _reent *, const void *, size_t _size, size_t _n, FILE *); 375 // size_t _fwrite_unlocked_r (struct _reent *, const void *, size_t _size, size_t _n, FILE *); 376 // int _getc_r (struct _reent *, FILE *); 377 // int _getc_unlocked_r (struct _reent *, FILE *); 378 // int _getchar_r (struct _reent *); 379 // int _getchar_unlocked_r (struct _reent *); 380 // char * _gets_r (struct _reent *, char *); 381 // int _iprintf_r (struct _reent *, const(char*), ...) 382 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 383 // int _iscanf_r (struct _reent *, const(char*), ...) 384 // _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); 385 // FILE * _open_memstream_r (struct _reent *, char **, size_t *); 386 // void _perror_r (struct _reent *, const(char*)); 387 // int _printf_r (struct _reent *, const(char*), ...) 388 // _ATTRIBUTE ((__format__ (__printf__, 2, 3))); 389 // int _putc_r (struct _reent *, int, FILE *); 390 // int _putc_unlocked_r (struct _reent *, int, FILE *); 391 // int _putchar_unlocked_r (struct _reent *, int); 392 // int _putchar_r (struct _reent *, int); 393 // int _puts_r (struct _reent *, const(char*)); 394 // int _remove_r (struct _reent *, const(char*)); 395 // int _rename_r (struct _reent *, 396 // const(char*)_old, const(char*)_new); 397 // int _scanf_r (struct _reent *, const(char*), ...) 398 // _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); 399 // int _siprintf_r (struct _reent *, char *, const(char*), ...) 400 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 401 // int _siscanf_r (struct _reent *, const(char*), const(char*), ...) 402 // _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); 403 // int _sniprintf_r (struct _reent *, char *, size_t, const(char*), ...) 404 // _ATTRIBUTE ((__format__ (__printf__, 4, 5))); 405 // int _snprintf_r (struct _reent *, char *, size_t, const(char*), ...) 406 // _ATTRIBUTE ((__format__ (__printf__, 4, 5))); 407 // int _sprintf_r (struct _reent *, char *, const(char*), ...) 408 // _ATTRIBUTE ((__format__ (__printf__, 3, 4))); 409 // int _sscanf_r (struct _reent *, const(char*), const(char*), ...) 410 // _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); 411 // char * _tempnam_r (struct _reent *, const(char*), const(char*)); 412 // FILE * _tmpfile_r (struct _reent *); 413 // char * _tmpnam_r (struct _reent *, char *); 414 // int _ungetc_r (struct _reent *, int, FILE *); 415 // int _vasiprintf_r (struct _reent *, char **, const(char*), __VALIST) 416 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 417 // char * _vasniprintf_r (struct _reent*, char *, size_t *, const(char*), __VALIST) 418 // _ATTRIBUTE ((__format__ (__printf__, 4, 0))); 419 // char * _vasnprintf_r (struct _reent*, char *, size_t *, const(char*), __VALIST) 420 // _ATTRIBUTE ((__format__ (__printf__, 4, 0))); 421 // int _vasprintf_r (struct _reent *, char **, const(char*), __VALIST) 422 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 423 // int _vdiprintf_r (struct _reent *, int, const(char*), __VALIST) 424 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 425 // int _vdprintf_r (struct _reent *, int, const(char*), __VALIST) 426 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 427 // int _vfiprintf_r (struct _reent *, FILE *, const(char*), __VALIST) 428 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 429 // int _vfiscanf_r (struct _reent *, FILE *, const(char*), __VALIST) 430 // _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); 431 // int _vfprintf_r (struct _reent *, FILE *, const(char*), __VALIST) 432 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 433 // int _vfscanf_r (struct _reent *, FILE *, const(char*), __VALIST) 434 // _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); 435 // int _viprintf_r (struct _reent *, const(char*), __VALIST) 436 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 437 // int _viscanf_r (struct _reent *, const(char*), __VALIST) 438 // _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); 439 // int _vprintf_r (struct _reent *, const(char*), __VALIST) 440 // _ATTRIBUTE ((__format__ (__printf__, 2, 0))); 441 // int _vscanf_r (struct _reent *, const(char*), __VALIST) 442 // _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); 443 // int _vsiprintf_r (struct _reent *, char *, const(char*), __VALIST) 444 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 445 // int _vsiscanf_r (struct _reent *, const(char*), const(char*), __VALIST) 446 // _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); 447 // int _vsniprintf_r (struct _reent *, char *, size_t, const(char*), __VALIST) 448 // _ATTRIBUTE ((__format__ (__printf__, 4, 0))); 449 // int _vsnprintf_r (struct _reent *, char *, size_t, const(char*), __VALIST) 450 // _ATTRIBUTE ((__format__ (__printf__, 4, 0))); 451 // int _vsprintf_r (struct _reent *, char *, const(char*), __VALIST) 452 // _ATTRIBUTE ((__format__ (__printf__, 3, 0))); 453 // int _vsscanf_r (struct _reent *, const(char*), const(char*), __VALIST) 454 // _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); 455 456 // /* Other extensions. */ 457 458 // int fpurge (FILE *); 459 // ssize_t __getdelim (char **, size_t *, int, FILE *); 460 // ssize_t __getline (char **, size_t *, FILE *); 461 462 // #if __MISC_VISIBLE 463 // void clearerr_unlocked (FILE *); 464 // int feof_unlocked (FILE *); 465 // int ferror_unlocked (FILE *); 466 // int fileno_unlocked (FILE *); 467 // int fflush_unlocked (FILE *); 468 // int fgetc_unlocked (FILE *); 469 // int fputc_unlocked (int, FILE *); 470 // size_t fread_unlocked (void *, size_t _size, size_t _n, FILE *); 471 // size_t fwrite_unlocked (const void * , size_t _size, size_t _n, FILE *); 472 // #endif 473 474 // #if __GNU_VISIBLE 475 // char * fgets_unlocked (char *, int, FILE *); 476 // int fputs_unlocked (const(char*), FILE *); 477 // #endif 478 479 // #ifdef __LARGE64_FILES 480 // #if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB) 481 // FILE * fdopen64 (int, const(char*)); 482 // FILE * fopen64 (const(char*), const(char*)); 483 // FILE * freopen64 (const(char*), const(char*), FILE *); 484 // _off64_t ftello64 (FILE *); 485 // _off64_t fseeko64 (FILE *, _off64_t, int); 486 // int fgetpos64 (FILE *, _fpos64_t *); 487 // int fsetpos64 (FILE *, const _fpos64_t *); 488 // FILE * tmpfile64 (void); 489 490 // FILE * _fdopen64_r (struct _reent *, int, const(char*)); 491 // FILE * _fopen64_r (struct _reent *,const(char*), const(char*)); 492 // FILE * _freopen64_r (struct _reent *, const(char*), const(char*), FILE *); 493 // _off64_t _ftello64_r (struct _reent *, FILE *); 494 // _off64_t _fseeko64_r (struct _reent *, FILE *, _off64_t, int); 495 // int _fgetpos64_r (struct _reent *, FILE *, _fpos64_t *); 496 // int _fsetpos64_r (struct _reent *, FILE *, const _fpos64_t *); 497 // FILE * _tmpfile64_r (struct _reent *); 498 // #endif /* !__CYGWIN__ */ 499 // #endif /* __LARGE64_FILES */ 500 501 // /* 502 // * Routines internal to the implementation. 503 // */ 504 505 // int __srget_r (struct _reent *, FILE *); 506 // int __swbuf_r (struct _reent *, int, FILE *); 507 508 // /* 509 // * Stdio function-access interface. 510 // */ 511 512 // #if __BSD_VISIBLE 513 // # ifdef __LARGE64_FILES 514 // FILE *funopen (const void *__cookie, 515 // int (*__readfn)(void *__c, char *__buf, 516 // _READ_WRITE_BUFSIZE_TYPE __n), 517 // int (*__writefn)(void *__c, const(char*)__buf, 518 // _READ_WRITE_BUFSIZE_TYPE __n), 519 // _fpos64_t (*__seekfn)(void *__c, _fpos64_t __off, int __whence), 520 // int (*__closefn)(void *__c)); 521 // FILE *_funopen_r (struct _reent *, const void *__cookie, 522 // int (*__readfn)(void *__c, char *__buf, 523 // _READ_WRITE_BUFSIZE_TYPE __n), 524 // int (*__writefn)(void *__c, const(char*)__buf, 525 // _READ_WRITE_BUFSIZE_TYPE __n), 526 // _fpos64_t (*__seekfn)(void *__c, _fpos64_t __off, int __whence), 527 // int (*__closefn)(void *__c)); 528 // # else 529 // FILE *funopen (const void *__cookie, 530 // int (*__readfn)(void *__cookie, char *__buf, 531 // _READ_WRITE_BUFSIZE_TYPE __n), 532 // int (*__writefn)(void *__cookie, const(char*)__buf, 533 // _READ_WRITE_BUFSIZE_TYPE __n), 534 // fpos_t (*__seekfn)(void *__cookie, fpos_t __off, int __whence), 535 // int (*__closefn)(void *__cookie)); 536 // FILE *_funopen_r (struct _reent *, const void *__cookie, 537 // int (*__readfn)(void *__cookie, char *__buf, 538 // _READ_WRITE_BUFSIZE_TYPE __n), 539 // int (*__writefn)(void *__cookie, const(char*)__buf, 540 // _READ_WRITE_BUFSIZE_TYPE __n), 541 // fpos_t (*__seekfn)(void *__cookie, fpos_t __off, int __whence), 542 // int (*__closefn)(void *__cookie)); 543 // # endif /* !__LARGE64_FILES */ 544 545 // # define fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \ 546 // (fpos_t (*)())0, (int (*)())0) 547 // # define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \ 548 // (fpos_t (*)())0, (int (*)())0) 549 // #endif /* __BSD_VISIBLE */ 550 551 // #if __GNU_VISIBLE 552 // typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n); 553 // typedef ssize_t cookie_write_function_t(void *__cookie, const(char*)__buf, 554 // size_t __n); 555 // # ifdef __LARGE64_FILES 556 // typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off, 557 // int __whence); 558 // # else 559 // typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence); 560 // # endif /* !__LARGE64_FILES */ 561 // typedef int cookie_close_function_t(void *__cookie); 562 // typedef struct 563 // { 564 // /* These four struct member names are dictated by Linux; hopefully, 565 // they don't conflict with any macros. */ 566 // cookie_read_function_t *read; 567 // cookie_write_function_t *write; 568 // cookie_seek_function_t *seek; 569 // cookie_close_function_t *close; 570 // } cookie_io_functions_t; 571 // FILE *fopencookie (void *__cookie, 572 // const(char*)__mode, cookie_io_functions_t __functions); 573 // FILE *_fopencookie_r (struct _reent *, void *__cookie, 574 // const(char*)__mode, cookie_io_functions_t __functions); 575 // #endif /* __GNU_VISIBLE */ 576 577 // #ifndef __CUSTOM_FILE_IO__ 578 // /* 579 // * The __sfoo macros are here so that we can 580 // * define function versions in the C library. 581 // */ 582 // #define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++)) 583 584 // #ifdef __SCLE 585 // /* For a platform with CR/LF, additional logic is required by 586 // __sgetc_r which would otherwise simply be a macro; therefore we 587 // use an inlined function. The function is only meant to be inlined 588 // in place as used and the function body should never be emitted. 589 590 // There are two possible means to this end when compiling with GCC, 591 // one when compiling with a standard C99 compiler, and for other 592 // compilers we're just stuck. At the moment, this issue only 593 // affects the Cygwin target, so we'll most likely be using GCC. */ 594 595 // _ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p); 596 597 // _ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p) 598 // { 599 // int __c = __sgetc_raw_r(__ptr, __p); 600 // if ((__p->_flags & __SCLE) && (__c == '\r')) 601 // { 602 // int __c2 = __sgetc_raw_r(__ptr, __p); 603 // if (__c2 == '\n') 604 // __c = __c2; 605 // else 606 // ungetc(__c2, __p); 607 // } 608 // return __c; 609 // } 610 // #else 611 // #define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p) 612 // #endif 613 614 // #ifdef __GNUC__ 615 // _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { 616 // #ifdef __SCLE 617 // if ((_p->_flags & __SCLE) && _c == '\n') 618 // __sputc_r (_ptr, '\r', _p); 619 // #endif 620 // if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) 621 // return (*_p->_p++ = _c); 622 // else 623 // return (__swbuf_r(_ptr, _c, _p)); 624 // } 625 // #else 626 // /* 627 // * This has been tuned to generate reasonable code on the vax using pcc 628 // */ 629 // #define __sputc_raw_r(__ptr, __c, __p) \ 630 // (--(__p)->_w < 0 ? \ 631 // (__p)->_w >= (__p)->_lbfsize ? \ 632 // (*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \ 633 // (int)*(__p)->_p++ : \ 634 // __swbuf_r(__ptr, '\n', __p) : \ 635 // __swbuf_r(__ptr, (int)(__c), __p) : \ 636 // (*(__p)->_p = (__c), (int)*(__p)->_p++)) 637 // #ifdef __SCLE 638 // #define __sputc_r(__ptr, __c, __p) \ 639 // ((((__p)->_flags & __SCLE) && ((__c) == '\n')) \ 640 // ? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \ 641 // __sputc_raw_r((__ptr), (__c), (__p))) 642 // #else 643 // #define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p) 644 // #endif 645 // #endif 646 647 // #define __sfeof(p) ((int)(((p)->_flags & __SEOF) != 0)) 648 // #define __sferror(p) ((int)(((p)->_flags & __SERR) != 0)) 649 // #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) 650 // #define __sfileno(p) ((p)->_file) 651 652 // #ifndef __cplusplus 653 // #ifndef _REENT_SMALL 654 // #define feof(p) __sfeof(p) 655 // #define ferror(p) __sferror(p) 656 // #define clearerr(p) __sclearerr(p) 657 658 // #if __MISC_VISIBLE 659 // #define feof_unlocked(p) __sfeof(p) 660 // #define ferror_unlocked(p) __sferror(p) 661 // #define clearerr_unlocked(p) __sclearerr(p) 662 // #endif /* __MISC_VISIBLE */ 663 // #endif /* _REENT_SMALL */ 664 665 // #if 0 /* __POSIX_VISIBLE - FIXME: must initialize stdio first, use fn */ 666 // #define fileno(p) __sfileno(p) 667 // #endif 668 669 // static __inline int 670 // _getchar_unlocked(void) 671 // { 672 // struct _reent *_ptr; 673 674 // _ptr = _REENT; 675 // return (__sgetc_r(_ptr, _stdin_r(_ptr))); 676 // } 677 678 // static __inline int 679 // _putchar_unlocked(int _c) 680 // { 681 // struct _reent *_ptr; 682 683 // _ptr = _REENT; 684 // return (__sputc_r(_ptr, _c, _stdout_r(_ptr))); 685 // } 686 687 // #ifdef __SINGLE_THREAD__ 688 // #define getc(_p) __sgetc_r(_REENT, _p) 689 // #define putc(_c, _p) __sputc_r(_REENT, _c, _p) 690 // #define getchar() _getchar_unlocked() 691 // #define putchar(_c) _putchar_unlocked(_c) 692 // #endif /* __SINGLE_THREAD__ */ 693 694 // #if __MISC_VISIBLE || __POSIX_VISIBLE 695 // #define getchar_unlocked() _getchar_unlocked() 696 // #define putchar_unlocked(_c) _putchar_unlocked(_c) 697 // #endif 698 // #endif /* __cplusplus */ 699 700 // #if __MISC_VISIBLE 701 // /* fast always-buffered version, true iff error */ 702 // #define fast_putc(x,p) (--(p)->_w < 0 ? \ 703 // __swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0)) 704 // #endif 705 706 // #if __GNU_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600) 707 // #define L_cuserid 9 /* posix says it goes in stdio.h :( */ 708 // #endif 709 // #if __POSIX_VISIBLE 710 // #define L_ctermid 16 711 // #endif 712 713 // #else /* __CUSTOM_FILE_IO__ */ 714 715 // #define getchar() getc(stdin) 716 // #define putchar(x) putc(x, stdout) 717 718 // #if __MISC_VISIBLE || __POSIX_VISIBLE 719 // #define getchar_unlocked() getc_unlocked(stdin) 720 // #define putchar_unlocked(x) putc_unlocked(x, stdout) 721 // #endif 722 723 // #endif /* !__CUSTOM_FILE_IO__ */ 724 725 // _END_STD_C 726 727 // #if __SSP_FORTIFY_LEVEL > 0 728 // #include <ssp/stdio.h> 729 // #endif 730 731 // #endif /* _STDIO_H_ */